package com.example.first;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

import androidx.appcompat.app.AppCompatActivity;

public class ConfigActivity extends AppCompatActivity {
    private static final String TAG= "rate";
    EditText ed1;
    EditText ed2;
    EditText ed3;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_config);
        Intent intent = getIntent();
        Bundle bdl = intent.getExtras();
        float dollar2 = bdl.getFloat("key_dollar",0.0f);
        float euro2 = bdl.getFloat("key_euro",0.0f);
        float won2 = bdl.getFloat("key_won",0.0f);
//        float dollar2 = intent.getFloatExtra("dollar_key",0.0f);
//        float euro2 = intent.getFloatExtra("euro_key",0.0f);
//        float won2 = intent.getFloatExtra("won_key",0.0f);
//        Log.i(TAG,"oncreat:dollar2="+dollar2);
//        Log.i(TAG,"oncreat:Euro2="+euro2);
//        Log.i(TAG,"oncreat:won2="+won2);
        ed1 = findViewById(R.id.ed1);
        ed2 = findViewById(R.id.ed2);
        ed3 = findViewById(R.id.ed3);
        //把数据放入页面控件里，供用户修改
        ed1.setText(String.valueOf(dollar2));
        ed2.setText(String.valueOf(euro2));
        ed3.setText(String.valueOf(won2));
    }
    public void click(View btn){
        ed1 = findViewById(R.id.ed1);
        ed2 = findViewById(R.id.ed2);
        ed3 = findViewById(R.id.ed3);
        Intent intent= getIntent();
        Bundle bundle = new Bundle();
        float newDollar = Float.parseFloat(String.valueOf(ed1.getText()));
        float neweuro = Float.parseFloat(String.valueOf(ed2.getText()));
        float newwon = Float.parseFloat(String.valueOf(ed3.getText()));
        bundle.putFloat("key_dollar2",newDollar);
        bundle.putFloat("key_euro2",neweuro);
        bundle.putFloat("key_won2",newwon);
        intent.putExtras(bundle);
        setResult(6,intent);
        finish();
//        intent.putExtra("dollar_key",Float.parseFloat(String.valueOf(ed1.getText())));
//        intent.putExtra("euro_key",Float.parseFloat(String.valueOf(ed2.getText())));
//        intent.putExtra("won_key",Float.parseFloat(String.valueOf(ed3.getText())));
    }


}